package com.example.game.controller;

import com.example.game.domain.pojo.HmUser;
import com.example.game.service.Userservice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {

    @Autowired
    private Userservice userService;

    @RequestMapping("/save")
    public Object save() {
        HmUser hmUser = new HmUser();
        hmUser.setName("name" + "_" + System.currentTimeMillis());
        hmUser.setPassword("123456");
        int save = userService.save(hmUser);
        if (save > 0) {
            return "插入成功";
        } else {
            return "插入失败";
        }
    }

    @RequestMapping("/getMaster")
    public Object getMaster(int id) {
        HmUser master = userService.getMaster(id);
        return master;
    }

    @RequestMapping("/getSlave")
    public Object getSlave(int id) {
        HmUser master = userService.getSlave(id);
        return master;
    }
}
